<template>
  <el-dialog custom-class="wrapper-upload" v-model="isShow" @close="handleClose" @open="handleOpen">
    <Upload :headers="headers" @success="handleSuccess" @error="handleError" />
  </el-dialog>
</template>

<script lang="ts">
import {
  defineComponent,
} from 'vue';

import Upload from './Upload.vue';

export default defineComponent({
  name: 'WrapperLogin',
  components: {
    Upload
  },
  props: {
    headers: {
      type: Object
    }
  },
  data() {
    return {
      isShow: false
    }
  },
  methods: {
    handleClose() {
      this.isShow = false;
    },
    handleOpen() {
      this.isShow = true;
    },
    handleSuccess(response) {
      if (response.success) {
        this.$message.success(response.msg)
        setTimeout(() => {
          this.isShow = false;
          this.$router.go(0);
        }, 1000)
      } else {
        this.$message.error(response.msg)
      }
    },
    handleError(response) {
      this.$message.error(response.msg);
    }
  }
})
</script>

<style lang="scss">
.wrapper-upload {
}
</style>